package com.gbq.service.impl;

import com.gbq.mybatis.mapper.SynEntityMapper;
import com.gbq.redisVo.SynEntity;
import com.gbq.service.BaseService;
import com.gbq.service.RedisService;
import com.gbq.util.BaseUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class BaseServiceImpl implements BaseService {

    @Autowired
    private SynEntityMapper synEntityMapper;


    @Autowired
    private RedisService redisService;

    @Override
    public String insert(SynEntity synEntity) {
        try {
            synEntityMapper.insert(synEntity.getField(), BaseUtils.getAllKey(synEntity.getObj()), synEntity.getObj());
            return "oracle inserted";
        } catch (Exception e) {
            log.info(e.toString());
            return "oracle failed";
        }

    }

    @Override
    public String delete(SynEntity synEntity) {

        try {
            synEntityMapper.delete(synEntity.getField(),synEntity.getObj());
            return "oracle deleted";
        } catch (Exception e) {
            log.info(e.toString());
            return "oracle failed";
        }

    }

    @Override
    public String update(SynEntity synEntity) {

        try {
            synEntityMapper.update(synEntity.getField(), BaseUtils.getAllKey(synEntity.getObj()), synEntity.getObj());
            return "oracle updated";
        } catch (Exception e) {
            log.info(e.toString());
            return "oracle failed";
        }
    }




    @Override
    public List<Object> selectList(String field) {
        return null;
    }

    @Override
    public Object selectOne(Object obj, String field) {
        return null;
    }



}
